package com.tdd.api.server.controller;


import com.tdd.api.server.domain.param.wx.app.UserInfoParam;
import com.tdd.api.server.domain.param.wx.app.UserOpenIdParam;
import com.tdd.api.server.domain.param.wx.app.UserPushParam;
import com.tdd.api.server.domain.param.wx.app.UserTokenParam;
import com.tdd.api.server.service.ITbUserOpenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author shaozq
 * @version V1.0.0
 * @description:${Description}
 * @date 2019/11/20 16:12
 * @copyright Copyright © 2019
 */
@Slf4j
@RestController
@Api(tags = "微信小程序")
@RequestMapping("/wx/app/")
public class WxAppController {

    @Resource
    private ITbUserOpenService userOpenService;


    @PostMapping("/save-user")
    @ApiOperation(value = "保存USER")
    @ResponseBody
    public String saveOpenId(@RequestBody UserInfoParam param) {
        log.info("user-openid >> {}", param);
        userOpenService.saveUser(param);
        return "SUCCESS";
    }


//    @PostMapping("/user-token")
//    @ApiOperation(value = "保存USER TOKEN")
//    @ResponseBody
//    public String saveToken(@RequestBody UserTokenParam param) {
//        log.info("user-token >> {}", param);
//        userOpenService.saveToken(param);
//        return "SUCCESS";
//    }


    @PostMapping("/user-push")
    @ResponseBody
    public String pushEnable(@RequestBody UserPushParam param) {
        log.info("user-push >> {}", param);
        userOpenService.pushEnable(param);
        return "SUCCESS";
    }


}
